package com.youge.springcloud.provider.controller;

import com.youge.springcloud.provider.model.User;
import org.springframework.web.bind.annotation.*;

/**
 * @author: hcf
 * @qq: 46914685
 * @email: 46914685@qq.com
 * @date: 2020-10-20 22:23
 */

@RestController
@RequestMapping("/provider")
public class ProviderController {

    @GetMapping("/hello")
    public String hello() throws InterruptedException {
        Thread.sleep(2000);
        System.out.println("hello springcloud provider service 01");
        return "hello springcloud provider service 01";
    }

    /**
     *
     * @return
     */
    @GetMapping("/user")
    public User user(){
        System.out.println("服务提供者1......");
        User user = new User();
        user.setId(108);
        user.setName("张三丰");
        user.setPhone("1380000000");
        return user;
    }

    /**
     *
     * @return
     */
    @GetMapping("/getUser")
    public User getUser(@RequestParam("id") Integer id, @RequestParam("name") String name, @RequestParam("phone") String phone){
        System.out.println("服务提供者1......");
        User user = new User();
        user.setId(id);
        user.setName(name);
        user.setPhone(phone);
        return user;
    }

    /**
     *
     * @return
     */
    @PostMapping("/addUser")
    public User addUser(@RequestParam("id") Integer id,
                        @RequestParam("name") String name,
                        @RequestParam("phone") String phone){
        System.out.println("服务提供者1......add");
        User user = new User();
        user.setId(id);
        user.setName(name);
        user.setPhone(phone);
        return user;
    }

    /**
     *
     * @return
     */
    @PutMapping("/updateUser")
    public User updateUser(@RequestParam("id") Integer id,
                        @RequestParam("name") String name,
                        @RequestParam("phone") String phone){
        System.out.println("服务提供者1......put");
        User user = new User();
        user.setId(id);
        user.setName(name);
        user.setPhone(phone);
        return user;
    }

    /**
     *
     * @return
     */
    @DeleteMapping("/deleteUser")
    public User deleteUser(@RequestParam("id") Integer id,
                           @RequestParam("name") String name,
                           @RequestParam("phone") String phone){
        System.out.println("服务提供者1......delete");
        User user = new User();
        user.setId(id);
        user.setName(name);
        user.setPhone(phone);
        return user;
    }



}

